package com.zlj.accountant.services;

import java.util.UUID;

import com.zlj.accountant.core.AbstractService;
import com.zlj.accountant.core.HandlerManager;
import com.zlj.accountant.core.ann.Publish;
import com.zlj.accountant.db.dao.DBHelper;
import com.zlj.accountant.db.entity.TAccountBank;
import com.zlj.accountant.publish.AccountType;
import com.zlj.accountant.publish.task.CreateAccountBankTask;
import com.zlj.accountant.publish.view.FAccountBank;

public class AccountBankPublicService extends AbstractService{

	public AccountBankPublicService(DBHelper dbHelper){
	    super(dbHelper);
    }
	
	
	@Publish
	protected final class GetFAccountBankByIdProvider extends OneKeyResultProvider<FAccountBank, UUID>{

		@Override
        public FAccountBank provide(HandlerManager handler, UUID id)
                throws Exception
        {
			FAccountBank r = new FAccountBank();
			TAccountBank a = handler.find(TAccountBank.class, id);
			r.balance = a.getIncome() - a.getOutgo();
			r.bankName = a.getBankName();
			r.code = a.getCardCode();
			r.id = a.getId();
			r.income = a.getIncome();
			r.outgo = a.getOutgo();
			r.accountType = AccountType.Bankcard;
			return r;
        }
		
	}
	
	
	
}
